import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:get/get.dart';

import 'index.dart';

class NotebookPreviewPage extends GetView<NotebookPreviewController> {
  const NotebookPreviewPage({super.key});

  Widget _buildView() {
    return Markdown(
      data: controller.mkNotebookModel.content??"",
      imageBuilder: (Uri uri, String? title, String? alt) {
        return Image.network(uri.toString());
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<NotebookPreviewController>(
      init: NotebookPreviewController(),
      id: "notebook_preview",
      builder: (_) {
        return Scaffold(
          appBar: AppBar(title: const Text("笔记预览")),
          body: SafeArea(
            child: _buildView(),
          ),
        );
      },
    );
  }
}
